package Q2;

import java.util.Scanner;

public class Main {

    public static int n;
    public static int[] arr;
    public static long ret = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        n = scanner.nextInt();
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        dfs(0, new boolean[n], false, 0);

        System.out.println(ret);

    }

    /**
     *
     * @param index
     * @param flag
     * @param prevFlag 前一个数是否选择
     */
    public static void dfs(int index, boolean[] flag, boolean prevFlag, long sum) {
        if (index == n) {
            ret = Math.max(ret, sum);

            return;
        }

        for (int i = index; i < n; i++) {
            if (prevFlag) {
                //前一个数被选择了
                dfs(i + 1, flag, false, sum);
            } else {
                //前一个数没有被选择
                //选
                flag[i] = true;
                dfs(i + 1, flag, true, sum + arr[i]);
                //回溯
                flag[i] = false;

                //不选
                dfs(i + 1, flag, false, sum);
            }
        }
    }
}
